package leet.ku._283;

public class Solution {
	
	public void moveZeroes(int[] nums) {
		int zeroPointer = 0;
		while (true) {
			
			// find the first zero
			while (zeroPointer < nums.length && nums[zeroPointer] != 0)
				zeroPointer++;
			if (zeroPointer >= nums.length)
				break;
			
			// find the next not zero
			int notZeroPointer = zeroPointer + 1;
			while (notZeroPointer < nums.length && nums[notZeroPointer] == 0)
				notZeroPointer++;
			if (notZeroPointer >= nums.length)
				break;
			
			nums[zeroPointer] = nums[notZeroPointer];
			nums[notZeroPointer] = 0;
			zeroPointer++;
		}
	}
	
}